/*
 * cMusic.cpp
 *
 *  Created on: 09.04.2012
 *      Author: NOR00
 */

#include "cMusic.h"

namespace strator {

cMusic::cMusic(const char* path){
	m_data = NULL;
	m_path = NULL;
	Load(path);
}

cMusic::~cMusic() {
	if (m_path!=NULL)
	{
		delete m_path;
		m_path = NULL;
	}
	if (m_data != NULL)
	{
		Mix_HaltMusic();
		Mix_FreeMusic(m_data);
		m_data = NULL;
	}
}

void cMusic::Load(const char *path)
{
	if (path != NULL)
	{
		m_path = (char*)path;
		m_data = Mix_LoadMUS(path);
	}
}

void cMusic::Play(bool loop)
{
	if (m_data != NULL)
	{
		Mix_PlayMusic(m_data, loop?-1:0);
	}
}

}
